import pygame

from Core.CScene import Scene
from Core.CImage import Image
from Core.CText import Text

from Scenes.CTestScene import TestScene
from Scenes.CMainScene import MainScene

class MenuScene(Scene):

  def __init__(self, screensize, audio):
    self.__b = Image("../data/graphics/background.jpg")
    self.__f = pygame.font.Font(None, 32)
    self.__screensize = screensize
    self.__startText = Text("Start\nLoad\nExit\nTest", self.__f, screensize[0])
    self.__audio = audio

    x, y = screensize
    x = x/2 - self.__startText.getWidth()/2
    y = y/2 - self.__startText.getHeight()/2

    self.__textrect = [x, y, x + self.__startText.getWidth(), y + self.__startText.getHeight()]

  def draw(self, graphics):
    self.__b.draw(graphics, [0, 0])
    self.__startText.draw(graphics, self.__textrect)

  def update(self, time):
    self.__b.update(time)

  def mouseInput(self, button, pos):
    if button == 0:
      if pos[0] >= self.__textrect[0] and pos[0] <= self.__textrect[2]:
        if pos[1] >= self.__textrect[1] and pos[1] <= self.__textrect[1]+20: #These positions are inaccurate.
          return MainScene("../data/scenes/main/intro.vnd", self.__screensize, self.__audio)
        #elif pos[1] >= self.__textrect[1]+20 and pos[1] <= self.__textrect[1]+39:
          #return LoadScene()
        #elif pos[1] >= self.__textrect[1]+40 and pos[1] <= self.__textrect[1]+59:
          #return ExitScene() #why would we want this in the first place? Lol.
        elif pos[1] >= self.__textrect[1]+70 and pos[1] <= self.__textrect[1]+90:
          return TestScene()
